package models;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import others.DumbFS;
import play.db.jpa.Model;

@Entity
public class Submission extends Model {
	private static final long serialVersionUID = -9109296410926888651L;

	public boolean toGrade = true;

	public double grade;

	public long time;

	// @Embedded
	// public FileAttachment file;

	@ManyToOne
	public Assignment assignment;

	@ManyToOne
	public Student student;

	public Submission () {
		time = new Date().getTime();
	}

	public File getFile() {
		return DumbFS.getInstance().getSubmission(this);
	}

	public static class Object {
		public long id;

		public double grade;

		public ArrayList<String> files;

		public Student.Object student;

		public Object (long id, double grade, Student.Object student, ArrayList<String> files) {
			this.id = id;
			this.grade = grade;
			this.student = student;
			this.files = files;
		}
	}
}
